package com.baizhiedu.baizhiappsys.orm;

import com.baizhiedu.baizhiappsys.entity.User;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.lang.Nullable;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;


/**
 * @author lby
 * 实现RowMapper接口，返回User对象
 */
public class UserRowMapper implements RowMapper<User> {

    @Nullable
    @Override
    public User mapRow(ResultSet resultSet, int i) throws SQLException {
        Integer id = resultSet.getInt(1);
        Date addTime = resultSet.getDate(2);
        String headImgUrl = resultSet.getString(3);
        Integer integral = resultSet.getInt(4);
        String nickname = resultSet.getString(5);
        String password = resultSet.getString(6);
        String phoneNumber = resultSet.getString(7);
        String weiXinOpenId = resultSet.getString(8);
        String gender = resultSet.getString(9);
        String email = resultSet.getString(10);
        Integer quan = resultSet.getInt(11);
        String invitationCode = resultSet.getString(12);
        Integer isPrivilege = resultSet.getInt(13);
        Integer deleteFlag = resultSet.getInt(14);

        return new User(id,addTime,headImgUrl,integral,nickname,password,phoneNumber,weiXinOpenId,gender,email,quan,invitationCode,isPrivilege,deleteFlag);
    }
}
